package com.zb.vo;

import com.zb.annotation.NumberPattern;
import com.zb.entity.ZjSysSetOverall;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @Author WEN
 * @Date 2023/7/26 0026
 **/
@Data
@ApiModel("系统全局设置实体封装")
public class SysSetOverallVo {

    @NotNull(message = "系统全局设置ID不能为空")
    @ApiModelProperty(value = "ID必传", required = true, example = "")
    private Long id;

    @NotNull(message = "地址等级类型选项不能为空")
    @NumberPattern(regexp = "^(1|2)$", message = "地址等级类型参数不合法！")
    @ApiModelProperty(value = "地址等级类型：1-四级，2-三级", required = true, example = "1")
    private Integer addressLevel;

    @Length(max = 10, message = "网站名称长度限制10个字符")
    @ApiModelProperty(value = "网站名称")
    private String websiteName;

    @Length(max = 200, message = "pc端首页logo图片路径长度限制在200个以内")
    @ApiModelProperty(value = "pc端首页logo图片路径，尺寸220*50", example = "")
    private String logo;

    @Length(max = 200, message = "pc端首页logo图片路径长度限制在200个以内")
    @ApiModelProperty(value = "pc端首页菜单栏收起的logo图片路径，尺寸220*50", example = "")
    private String reduceLogo;

    @Length(max = 200, message = "移动服务报单端LogoLogo路径长度限制在200个以内")
    @ApiModelProperty(value = "移动服务报单端LogoLogo", example = "")
    private String mobileServiceLogo;

    @Length(max = 200, message = "仓库移动端Logo路径长度限制在200个以内")
    @ApiModelProperty(value = "仓库移动端Logo", example = "")
    private String storeLogo;

    @ApiModelProperty(value = "创建时间", hidden = true)
    private Date createTime;

    @ApiModelProperty(value = "更新时间", hidden = true)
    private Date updateTime;

    public static SysSetOverallVo beanToVo(ZjSysSetOverall overall) {
        SysSetOverallVo vo = new SysSetOverallVo();
        BeanUtils.copyProperties(overall, vo);
        vo.setCreateTime(overall.getGmtCreate());
        vo.setUpdateTime(overall.getGmtUpdate());
        return vo;
    }

    public static ZjSysSetOverall voToBean(SysSetOverallVo vo) {
        ZjSysSetOverall overall = new ZjSysSetOverall();
        BeanUtils.copyProperties(vo, overall);
        return overall;
    }
}
